package com.example.mqttxconsumer.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer{
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        // 映射服务器中那些http接口进行跨域访问
        registry.addMapping("/**")
                // 配置哪些来源有权限跨域
                .allowedOrigins("*")
                // 配置运行跨域访问的请求方法
                .allowedMethods("GET", "POST", "DELETE", "PUT","OPTIONS");
    }
}
